package com.example.demo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.demo.JavaMail.SendMailText;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.List;

@SpringBootApplication
//开启定时任务
//@EnableScheduling
//开启异步调用任务
//@EnableAsync
public class DemoApplication{
	private static Logger logger = LoggerFactory.getLogger(DemoApplication.class);
	public static void main(String[] args) throws Exception{
		SpringApplication.run(DemoApplication.class, args);
		String message = "{'cell':['a','b']}";
		//String t = new String(message,"UTF-8");
		JSONObject jsonObj = JSON.parseObject(message);
		System.out.println(jsonObj);
		JSONArray cell = jsonObj.getJSONArray("cell");
		System.out.println(cell);
		List list = JSON.parseArray(cell.toString());
		System.out.println(list.get(0));
		Object[] strs = cell.toArray();
		System.out.println(strs[0]);

		//郵件功能測試
//		Thread thread = new Thread(new SendMailText(),"Mail Thread");
//		thread.start();
//		System.out.println(thread.getName());

		//字符串測試
		String s1 = "Programming";
		String s2 = new String(s1.getBytes("GB2312"),"UTF-8");
		String s3 = "Program";
		String s4 = "ming";
		String s5 = "Program" + "ming";
		String s6 = s3 + s4;
		System.out.println(s1 == s2);
		System.out.println(s1 == s5);
		System.out.println(s1 == s6);
		System.out.println(s1 == s6.intern());
		System.out.println(s2 == s2.intern());
	}
}
